<?php

    class ElementTableBrowseView extends Element {
        public function Render( $curpage ) {
            global $table;

            $numpages = ceil( $table->NumRows / PAGE_LIMIT ); // PAGE_LIMIT: libs/baboo
            if ( $curpage >= $numpages ) {
                $curpage = 0;
            }

            $offset = $curpage * PAGE_LIMIT;
            $rows = $table->FetchRows( $offset, PAGE_LIMIT );

            ?><div id="tablebrowse"><?php

                Element( 'table/metadata', $offset + 1, $table->NumRows, $curpage );

                ?><table class="browse" id="tabledata"><?php
                    Element( 'table/browse/title' );

                    $color = false;
                    foreach ( $rows as $row ) {
                        Element( 'table/browse/row', $row, $color );
                        $color = !$color;
                    }

                    Element( 'table/browse/insert', $color );
                ?></table><?php
                
                Element( 'table/pages', $curpage, $numpages );
            ?></div><?php
        }
    }

?>
